package com.coffee.service.impl;

import com.coffee.conmmon.BaseResult;
import com.coffee.dao.CoffeeMapper;
import com.coffee.entity.Coffee;
import com.coffee.entity.CoffeeAndCotype;
import com.coffee.entity.Cotype;
import com.coffee.service.CofferService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CofferServiceImpl  implements CofferService {

    @Resource
    CoffeeMapper coffeeMapper;
    @Override
    public BaseResult findAll(Integer cotid) {
        List<CoffeeAndCotype> all = coffeeMapper.findAll(cotid);
        BaseResult baseResult = new BaseResult();
        if(all!=null){
            baseResult.setCode(200);
            baseResult.setData(all);
            baseResult.setMessage("查询成功");
            return baseResult;
        }
            baseResult.setCode(201);
            baseResult.setMessage("查询失败");
        return baseResult;
    }

    @Override
    public BaseResult selectAll() {
        List<CoffeeAndCotype> coffeeAndCotypes = coffeeMapper.selectAll();
        BaseResult baseResult = new BaseResult();
        if(coffeeAndCotypes!=null){
            baseResult.setData(coffeeAndCotypes);
            baseResult.setCode(200);
            baseResult.setMessage("查询成功");
            return baseResult;
        }
        baseResult.setCode(201);
        baseResult.setMessage("查询失败");
        return baseResult;

    }

    @Override
    public BaseResult selectOne() {
        List<Cotype> aaa = coffeeMapper.selectOne();
        BaseResult baseResult = new BaseResult();
        if(aaa!=null){
            baseResult.setData(aaa);
            baseResult.setCode(200);
            baseResult.setMessage("查询成功");
            return baseResult;
        }
        baseResult.setCode(201);
        baseResult.setMessage("查询失败");
        return baseResult;
    }

    @Override
    public BaseResult goods() {
        List<Coffee> goods = coffeeMapper.goods();
        BaseResult baseResult = new BaseResult();
        if (goods != null) {
            baseResult.setData(goods);
            baseResult.setCode(200);
            baseResult.setMessage("查询成功");
            return baseResult;
        }
        baseResult.setCode(201);
        baseResult.setMessage("查询失败");
        return baseResult;
    }
}
